package com.javasoft.controller.YZX;


import com.javasoft.entity.WJC.StudentAnswer;
import com.javasoft.service.YZX._interface.PaperInquiryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("paper-inquiries")
public class PaperInquiryController {

    @Autowired
    private PaperInquiryService paperInquiryService;




    /**
     * 根据学生ID和考试ID查询答卷
     *
     * @param studentAnswer 包含 studentId 和 examId 的 StudentAnswer 对象。
     * @return 答卷信息
     */
    @PostMapping("/query")
    public ResponseEntity<StudentAnswer> getPaperInquiryByPost(@RequestBody StudentAnswer studentAnswer) {
        try {
            StudentAnswer result = paperInquiryService.findByStudentIdAndExamId(studentAnswer.getStudentId(), studentAnswer.getExamId());
            return ResponseEntity.ok(result);
        } catch (Exception e) {
            log.error("Error during query by POST: {}", e.getMessage(), e);
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
        }
    }



}